﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Input;

namespace DbDoc.PowerDoc.ViewModel
{
    public class DelegateCommand : ICommand
    {
        readonly Action<object> execute;
        readonly Predicate<object> canExecute; 

        public DelegateCommand(Action<object> executeMethod, Predicate<object> canExecuteMethod)
        {
            this.execute = executeMethod;
            this.canExecute = canExecuteMethod;
        }

        public DelegateCommand(Action<object> executeMethod)
        {
            this.execute = executeMethod;
            
        }

        public bool CanExecute(object parameter)
        {
            return canExecute == null ? true : canExecute(parameter);
        }

       
        public void Execute(object parameter)
        {
            execute(parameter);
        }

        public event EventHandler CanExecuteChanged;

    }
}
